#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/sched.h>  
#include <linux/types.h>
#include<linux/pid.h>

int my_pid = 5;
module_param(my_pid,int,0644);

static int __init my_test_init(void)
{   struct pid* pid = find_get_pid(my_pid);
   struct task_struct *p;
   p = pid_task(pid,PIDTYPE_PID);
   printk("=====================================================\n");
    printk("pid为%d的信息如下：\n",my_pid);
if(p){
     printk("name: %s, \tpid: %d, \tstate: %d, \texit_state: %d, \texit_code: %d, \texit_signal: %d, \tparent_pid: %d, \tparent_name: %s,  \tutime: %ld, \tstime: %d\n",
		     p->comm,p->pid,
		     p->__state,
		     p->exit_state,
		     p->exit_code,
		     p->exit_signal,
		     (p->parent)->pid,
		     (p->parent)->comm,
		     p->utime,
		     p->stime);
}          
     
    return 0;
}
static void __exit my_test_exit(void)
{
    printk("goodbye\n");
}
module_init(my_test_init);
module_exit(my_test_exit);
MODULE_LICENSE("GPL");

